package com.example.application1;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.example.application1.Adapter.expressAdapter;
import com.example.application1.Entity.ListDTO;
import com.example.application1.Entity.NewslistDTOX;
import com.example.application1.tools.DividerGridItemDecoration;

import java.util.List;


public class ExpressActivity extends AppCompatActivity {

    private List<NewslistDTOX> expressList;
    private TextView express_status;
    private TextView express_updateTime;
    private TextView express_company;
    private TextView express_phone;
    private RecyclerView ExpressRecycleView;
    private List<ListDTO> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_express);

        Intent intent=getIntent();



        initView();
//        setTextView();
//        useAdapterInitView();
    }

    public void initView(){
        express_status=findViewById(R.id.express_status);
        express_updateTime=findViewById(R.id.express_updateTime);
        express_company=findViewById(R.id.express_company);
        express_phone=findViewById(R.id.express_phone);
        ExpressRecycleView=findViewById(R.id.ExpressRecycleView);
    }

    public void setTextView(){
//        -1待查询、0查询异常、1暂无记录、2在途中、
//        3 派送中、4已签收、5用户拒签、6疑难件、
//        7无效单、8超时单、9签收失败、10退回
        express_phone.setText(expressList.get(0).getTelephone());
        express_company.setText(expressList.get(0).getKuaidiname());
        express_updateTime.setText(expressList.get(0).getUpdatetime());
        switch (expressList.get(0).getStatus()){
            case -1:express_status.setText("待查询");
            break;
            case 0:express_status.setText("查询异常");
            break;
            case 1:express_status.setText("暂无记录");
            break;
            case 2:express_status.setText("在途中");
            break;
            case 3:express_status.setText("派送中");
            break;
            case 4:express_status.setText("已签收");
            break;
            case 5:express_status.setText("用户拒签");
            break;
            case 6:express_status.setText("疑难件");
            break;
            case 7:express_status.setText("无效单");
            break;
            case 8:express_status.setText("超时单");
            break;
            case 9:express_status.setText("签收失败");
            break;
            case 10:express_status.setText("退回");
            break;
            default:express_status.setText("没有订单");
            break;
        }
    }

    public void useAdapterInitView(){
        ExpressRecycleView.setLayoutManager(new LinearLayoutManager(this));
        expressAdapter adapter=new expressAdapter(this,list);
        ExpressRecycleView.setAdapter(adapter);
        ExpressRecycleView.addItemDecoration(new DividerGridItemDecoration(this));
        adapter.refresh(list);
    }

}